<template>
  <div class="el-badge-clas">
    <!--    <svg-icon icon-class="github" @click="goto"/>-->
    <el-badge :value="newUnreadMsg" :max="99" v-if="newUnreadMsg > 0">
      <svg-icon icon-class="lingdang" @click="toFeedback" />
    </el-badge>
    <el-badge v-else="">
      <svg-icon icon-class="lingdang" @click="toFeedback" />
    </el-badge>
  </div>
</template>
<script>
import { getUnreadMsgCount } from '@/api/biz'

export default {
  name: 'UnReadNew',
  data () {
    return {
      newUnreadMsg: 0
    }
  },
  mounted () {
    // this.getUnreadMsgCountFn();
    // const unreadNewTimer = setInterval(()=>{
    //   this.getUnreadMsgCountFn();
    // },1000)
    // this.$once('hook:beforeDestroy', ()=>{
    //   clearInterval(unreadNewTimer)
    // })
  },
  methods: {
    //查询未读消息条数
    getUnreadMsgCountFn () {
      getUnreadMsgCount().then(response => {
        if (response.code == '200') {
          this.newUnreadMsg = Number(response.msg)
        }
      });
    },
    toFeedback () {
      this.$router.push({ path: "/feedback" });
    }
  }
}
</script>
<style lang="scss">
.el-badge-clas {
  .el-badge__content.is-fixed {
    top: 15px;
  }
}
</style>
